package com.instala;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletURL;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.liferay.util.bridges.mvc.MVCPortlet;

/**
 * Portlet implementation class Faltante
 */
public class Faltante extends MVCPortlet {
	
	
	protected String viewJSP;
	private static Log _log = LogFactory.getLog(Faltante.class);
	// public static String namePermissions = "com.sanminasci.qcpPermission";
	// public Permisos vpermisos;// Name
	// of
	// the
	// memory
	// object

	public void init(PortletConfig portletConfig) throws PortletException
	{
		super.init(portletConfig);		
		viewJSP = getInitParameter("view-template");
	}

	public void doView(RenderRequest renderRequest,
			RenderResponse renderResponse) throws IOException, PortletException
	{
		String path = renderRequest.getContextPath();

		renderResponse.setContentType("text/html");
		System.out.println("PortletUrl 2");
		PortletURL Url = renderResponse.createActionURL();
		Url.setParameter("faltanteUrl", "faltanteUrl");
		renderRequest.setAttribute("faltanteUrl", Url.toString());
		
		include(viewJSP, renderRequest, renderResponse); 
	}

	protected void include(String path, RenderRequest renderRequest,
			RenderResponse renderResponse) throws IOException, PortletException
	{
		try
		{
			System.out.println("begin include");
			PortletRequestDispatcher portletRequestDispatcher = getPortletContext()
					.getRequestDispatcher(path);
			if (portletRequestDispatcher == null)
			{
				_log.error(path + " is not a valid include");
			} else
			{
				portletRequestDispatcher.include(renderRequest, renderResponse);
			}
		} catch (Exception e)
		{
			System.out.println(e);
		}
		System.out.println("finish include");
	}

	public void processAction(ActionRequest actionRequest,
			ActionResponse actionResponse) throws IOException, PortletException
	{
		System.out.println("entro doaction");
		String qcpUrl = actionRequest.getParameter("faltanteUrl");
		boolean answered = false;

	
	}
 

}
